﻿using BaBaoFan.Modifier.Common;
using BaBaoFan.Modifier.Data;
using BaBaoFan.Modifier.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace BaBaoFan.Modifier.Service
{
    public class UserInfoService : IUserInfoService
    {
        private readonly IUserInfoRepository _userInfoRepository;
        public UserInfoService(IUserInfoRepository userInfoRepository)
        {
            _userInfoRepository = userInfoRepository;
        }
        public UserInfo Login(string userName, string password)
        {
            var user = _userInfoRepository.GetUserByName(userName);
            if (user != null)
            {
                if (user.Password == Encryption.GetMD5(password)&&user.IsEnable==0)
                    return user;
                else
                    return null;
            }
            return user;
        }
    }
}
